public class PESampleDeal
{
    String peId = System.currentPageReference().getParameters().get('id');
    PE_Sample_Management__c pe = [Select id, Deal__c From PE_Sample_Management__c Where id =: peId];
    List<RegionalBudget__c> RBList = [Select id,ownerid,SRMMM__c,SRMMM__r.email,Region__c From RegionalBudget__c Where PESampleManagement__c =: peId];
    public PageReference Deal() {
        pe.Deal__c = true;
        update pe;
        
        for(RegionalBudget__c rb : RBList)
        {
            rb.ownerid = rb.SRMMM__c;
            rb.Approved__c = true;
            String emailAddresses = rb.SRMMM__r.email;
            List<String> toAddresses = new List<String>();
            toAddresses.add( emailAddresses );  
            List<String> ccAddresses = new List<String>();
            String Body = '您好！\n' +  '您可以分配' + rb.Region__c + '专业样品管理!\n' + string.valueof(Date.Today());
            String Subject = rb.Region__c + '专业样品管理分配';
                    
            EmailFunction.SendEmail(toAddresses, ccAddresses, Body, Subject);                  
            
            
        }
        update RBList;

        PageReference pr=new PageReference('/'+peId);
        pr.setRedirect(true);
        return pr;
    
    }



}